﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace SchEdu.Framework.Objective
{
    class TardyJobs : Objective
    {
        public TardyJobs()
            : base()
        {
        }
        public TardyJobs(SchEduData schEduData, SchEduDataSet.SolutionRow solution)
            : base(schEduData, solution)
        {
        }
        protected override void Logic()
        {
            int lateJobs = 0;

            foreach (SchEduDataSet.OrderRow order in SchEduData.Order)
            {

                if (order.DueDate < order.EndDate)
                {
                    lateJobs = lateJobs + 1;
                }
            }

            GeneratePerformanceRow();

            performance.Value = lateJobs;


        }

        protected override void InitializeValidators()
        {
            base.InitializeValidators();
            validators.Add(new OrderDueDateValidator(SchEduData));
            validators.Add(new OrderEndDateValidator(SchEduData));
        }

        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "Tardy Jobs";
                aboutInfo.Guid = new Guid("{604E11B3-B330-4582-964E-1DF0D4A5DC04}");
                aboutInfo.Description = Resources.TardyJobsDescription;
                return aboutInfo;
            }
        }

    }
}
